package chen.web.user;

import java.util.List;

import chen.web.event.method.EventType;

public interface AccountManager{	

	public static final String ME_Delete_Account = "ME_Delete_Account";
	/**
	 * 删除用户账号
	 * @param account	用户帐号
	 */
	@EventType(type=ME_Delete_Account)
	void deleteAccount(Account account);

	
	public static final String ME_Get_Account_By_Id = "ME_Get_Account_By_Id";
	/**
	 * 根据账号id获得用户账号
	 * @param id	账号id
	 * @return	用户账号
	 */
	@EventType(type=ME_Get_Account_By_Id)
	Account getAccount(int id);
	
	public static final String ME_Get_Account_By_Ids = "ME_Get_Account_By_Ids";
	/**
	 * 根据账号id获得用户账号集合
	 * @param ids	账号id集合
	 * @return	用户账号集合，保证返回的集合大小和顺序与参数一致
	 */
	@EventType(type=ME_Get_Account_By_Ids)
	List<Account> getAccount(List<Integer> ids);
	

	public static final String ME_Get_Account_By_Name = "ME_Get_Account_By_Name";
	/**
	 * 根据账号昵称获得用户账号
	 * @param nickname	账号昵称
	 * @return	用户账号
	 */
	@EventType(type=ME_Get_Account_By_Name)
	Account getAccountByName(String nickname);
	
	public static final String ME_Get_Account_By_Email = "ME_Get_Account_By_Email";
	@EventType(type=ME_Get_Account_By_Email)
	Account getAccountByEmail(String email);

	public static final String ME_Change_My_Password = "ME_Change_My_Password";
	@EventType(type=ME_Change_My_Password)
	Account changePassword(String newPassword, String oldPassword) throws InvalidPasswordException;
	
	public static final String ME_Change_Password = "ME_Change_Password";
	@EventType(type=ME_Change_Password)
	Account changePassword(Account account, String newPassword);
	
	
	public static final String ME_Change_Email = "ME_Change_Email";
	@EventType(type=ME_Change_Email)
	Account changeEmail(Account account, String newEmail) throws EmailAlreadyBeenRegisteredException;
	
	public static final String ME_Change_My_Email = "ME_Change_My_Email";
	@EventType(type=ME_Change_My_Email)
	Account changeEmail(String email, String password) throws InvalidPasswordException, EmailAlreadyBeenRegisteredException;
	
	public static final String ME_Update_Extension_Info = "ME_Update_Extension_Info";
	/**
	 * 更改帐号信息
	 * @param account
	 */
	@EventType(type=ME_Update_Extension_Info)
	void update(Account account);
	
	public static final String ME_Change_Role = "ME_Change_Role";
	@EventType(type=ME_Change_Role)
	Account changeRole(Account account, Role role);
	
	public static final String ME_Register = "ME_Register";
	/**
	 * 会员注册，注册后会获得一个访客角色帐号
	 * @param account	需要注册的帐号
	 * @return 注册成功的帐号
	 * @throws NicknameAlreadyBeenRegisteredException 
	 * @throws EmailAlreadyBeenRegisteredException 
	 */
	@EventType(type=ME_Register)
	Account register(String nickname, String password, String email) throws NicknameAlreadyBeenRegisteredException, EmailAlreadyBeenRegisteredException;

	public static final String ME_Increase_Rank = "ME_Increase_Rank";
	/**
	 * 改更帐号权重, 参数increase为负时，表示减少积分．
	 * @param account
	 * @param increase
	 */
	@EventType(type=ME_Increase_Rank)
	Account increaseRank(Account account, int increase);
	
	public static final String ME_Total_Account = "ME_Total_Account";
	@EventType(type=ME_Total_Account)
	int totalAccount();
	
	public static final String ME_Merge_Account = "ME_Merge_Account";
 	/**
	 * 合并角色中的帐号，将所有角色是oldRole的帐号改为newRole．
	 * @param role		
	 * @param target
	 */
	@EventType(type=ME_Merge_Account)
	void mergeAccount(Role oldRole, Role newRole);

}